package searchme.util;

import java.io.*;
import java.util.Hashtable;

public class Stopword {
	private static final Hashtable<String, Integer> stopwordList = getStopword();

	private static Hashtable<String, Integer> getStopword() {
		Hashtable<String, Integer> stopwords = new Hashtable<String, Integer>();
		try {
			BufferedReader input = new BufferedReader(
					new FileReader("STOPWORD"));
			try {
				String line = null;
				while ((line = input.readLine()) != null) {
					stopwords.put(line, 1);
				}
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				input.close();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		return stopwords;
	}

	/**
	 * to check whether the given word is stopword
	 * 
	 * @param word
	 *            the word to be checked
	 * @return return true if the word is stopword else return false
	 */
	public boolean isStopword(String word) {
		if (stopwordList.containsKey(word))
			return true;
		else
			return false;
	}

	// public static void main(String[] args) {
	// Stopword stopword = new Stopword();
	//
	// }

}
